<?php
error_reporting(E_ERROR);
@set_time_limit(1000);
set_magic_quotes_runtime(0);
define('TIME', time());
define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
define('PHPCMS_ROOT', str_replace("\\", '/', dirname(__FILE__)).'/');
if(file_exists(PHPCMS_ROOT.'data/install.lock')) exit('您已经安装过PHPCMS,如果需要重新安装，请删除 ./data/install.lock 文件！');
define('IN_PHPCMS',true);
set_include_path(PHPCMS_ROOT.'include/');

require 'config.inc.php';
require 'version.inc.php';
require 'global.func.php';
require 'admin/global.func.php';
require 'dir.func.php';

define('IP', ip());
define('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : preg_replace("/(.*)\.php(.*)/i", "\\1.php", $_SERVER['PHP_SELF']));
define('QUERY_STRING', $_SERVER['QUERY_STRING']);
define('PATH_INFO', isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '');
define('DOMAIN', isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : preg_replace("/([^:]*)[:0-9]*/i", "\\1", $_SERVER['HTTP_HOST']));
define('SCHEME', $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://');
define('SITE_URL', SCHEME.$_SERVER['HTTP_HOST'].PHPCMS_PATH);
define('RELATE_URL', isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : SCRIPT_NAME.(QUERY_STRING ? '?'.QUERY_STRING : PATH_INFO));
define('URL', SCHEME.$_SERVER['HTTP_HOST'].RELATE_URL);
define('SKIN_PATH', 'templates/default/skins/default/phpcms');

$siteUrl = SCHEME.dirname($_SERVER['HTTP_HOST'].$_SERVER["SCRIPT_NAME"]);

if($_REQUEST)
{
	if(!MAGIC_QUOTES_GPC)
	{
		$_REQUEST = new_addslashes($_REQUEST);
		if($_COOKIE) $_COOKIE = new_addslashes($_COOKIE);
	}
	extract($_REQUEST, EXTR_SKIP);
}

header('Content-type: text/html; charset='.CHARSET);

$steps = include PHPCMS_ROOT.'install/step.inc.php';
if(!isset($step)) $step = '1';

if(strrpos(strtolower(PHP_OS),"win") === FALSE)
{
	define('ISUNIX', TRUE);
}
else
{
	define('ISUNIX', FALSE);
}
$mode = 0777;

switch($step)
{
    case '1': //安装须知
		include PHPCMS_ROOT."install/step".$step.".tpl.php";

		break;
	case '2': //许可协议
		$license = file_get_contents(PHPCMS_ROOT."install/license.txt");
		include PHPCMS_ROOT."install/step".$step.".tpl.php";
		break;

	case '3': //环境检测 (FTP帐号设置）
        $PHP_GD = '';
		if(extension_loaded('gd'))
	    {
			if(function_exists('imagepng')) $PHP_GD .= 'png';
			if(function_exists('imagejpeg')) $PHP_GD .= ' jpg';
			if(function_exists('imagegif')) $PHP_GD .= ' gif';
		}
        $PHP_DNS = preg_match("/^[0-9.]{7,15}$/", @gethostbyname('www.phpcms.cn')) ? 1 : 0;
		//是否满足phpcms安装需求
		$is_right = (phpversion() >= '4.3.0' && extension_loaded('mysql') && ini_get('short_open_tag')) ? 1 : 0;
		include PHPCMS_ROOT."install/step".$step.".tpl.php";
		break;
	case '4': //选择安装模块
		require PHPCMS_ROOT.'/install/modules.inc.php';

		include PHPCMS_ROOT."install/step".$step.".tpl.php";
		break;

	case '5': //设置目录属性
		$selectmod = isset($selectmod) ? ','.implode(',', $selectmod) : '';
		$selectmod = 'phpcms,member,pay'.$selectmod;
		$selectmods = explode(',',$selectmod);
		$selectmods = explode(',',$selectmod);
		foreach($selectmods AS $dir)
		{
			if($dir == 'phpcms')
			{
				$files = file(PHPCMS_ROOT."install/chmod.txt");
			}
			else
			{
				$files = file(PHPCMS_ROOT.$dir."/install/chmod.txt");
			}
			$files = array_filter($files);
			foreach($files as $file)
			{
				$file = str_replace('*','',$file);
				$file = trim($file);
				if(is_dir($file))
				{
					$cname = '目录';
				}
				else
				{
					$cname = '文件';
				}
				if(!is_writable(PHPCMS_ROOT.$file)) $no_writablefile .= $file.' '.$cname."不可写<br>";
			}
		}
		if(dir_create(PHPCMS_ROOT.'test_create_dir',0777))
		{
			sleep(1);
			dir_delete(PHPCMS_ROOT.'test_create_dir');
		}
		else
		{
			$no_writablefile = "网站根目录不可写<br>".$no_writablefile;
		}
		include PHPCMS_ROOT."install/step".$step.".tpl.php";
		break;

	case '6': //配置帐号 （MYSQL帐号、管理员帐号、）

		include PHPCMS_ROOT."install/step".$step.".tpl.php";
		break;

	case '7': //安装详细信息-完成安装

		include PHPCMS_ROOT."install/step".$step.".tpl.php";
		break;

	case 'installmodule': //执行SQL
		if($module == 'phpcms')
		{
			$cookie_pre = random(10, 'abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ');
			$auth_key = random(20, 'abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ');
			$PHP_SELF = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : (isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : $_SERVER['ORIG_PATH_INFO']);
			$rootpath = str_replace("\\","/",dirname($PHP_SELF));
			$rootpath = strlen($rootpath)>1 ? $rootpath."/" : "/";
			$config = array('DB_HOST'=>$dbhost,
						'DB_USER'=>$dbuser,
						'DB_PW'=>$dbpw,
						'DB_NAME'=>$dbname,
						'DB_PRE'=>$tablepre,
						'PHPCMS_PATH'=>$rootpath,
						'DB_PCONNECT'=>$pconnect,
						'DB_CHARSET'=>$dbcharset,
						'COOKIE_PRE'=>$cookie_pre,
						'PHPCMS_PATH'=>$rootpath,
						'AUTH_KEY'=>$auth_key,
						'ADMIN_EMAIL'=>$email,
						'PASSWORD_KEY'=>$password_key,
						);
			set_config($config);

			$config_js = "var phpcms_path = '$rootpath';\nvar cookie_pre = '$cookie_pre';\nvar cookie_domain = '';\nvar cookie_path = '/';";

			file_put_contents(PHPCMS_ROOT.'data/config.js', $config_js);
			@chmod(PHPCMS_ROOT.'data/config.js', 0777);
			$dbclass = 'db_'.DB_DATABASE;
			require $dbclass.'.class.php';

			$db = new $dbclass;
			$connid = $db->connect($dbhost, $dbuser, $dbpw, '', $pconnect);
			$version = mysql_get_server_info($connid);
			if($version > '4.1' && $dbcharset)
			{
				mysql_query("SET NAMES '$dbcharset'" , $connid);
			}
			if($version > '5.0')
			{
				mysql_query("SET sql_mode=''" , $connid);
			}
			if(!@$db->select_db($dbname))
			{
				@$db->query("CREATE DATABASE $dbname");
				if(@$db->error()) {
					echo 1;exit;
				} else {
					$db->select_db($dbname);
				}
			}
			$dbfile = $dbsolution ? 'phpcms_speed.sql' : 'phpcms_db.sql';
			if(file_exists(PHPCMS_ROOT."install/main/".$dbfile))
			{
				$sql = file_get_contents(PHPCMS_ROOT."install/main/".$dbfile);
				_sql_execute($sql);

			}
			else
			{
				echo '2';//数据库文件不存在
			}
            dir_copy(PHPCMS_ROOT.'install/templates/', PHPCMS_ROOT.'templates/'.TPL_NAME.'/phpcms/');
			$data = file_get_contents(PHPCMS_ROOT.'templates/'.TPL_NAME.'/phpcms/tag_config.inc.php');
			$data = str_replace('phpcms2008_', $tablepre, $data);
			file_put_contents(PHPCMS_ROOT.'templates/'.TPL_NAME.'/phpcms/tag_config.inc.php', $data);
		}
		else
		{
			$dbclass = 'db_'.DB_DATABASE;
			require $dbclass.'.class.php';

			$db = new $dbclass;
			$db->connect(DB_HOST, DB_USER, DB_PW, DB_NAME, DB_PCONNECT, DB_CHARSET);
			$db->query("DELETE FROM `".DB_PRE."module` WHERE module='$module'");
			if(file_exists(PHPCMS_ROOT.$module."/install/mysql.sql"))
			{
				$sql = file_get_contents(PHPCMS_ROOT.$module."/install/mysql.sql");
				sql_execute($sql);
			}
			else
			{
				echo 2;//数据库文件不存在
				exit;
			}
			if(file_exists(PHPCMS_ROOT.$module."/install/extention.inc.php"))
			{
				@extract($db->get_one("SELECT menuid AS member_0 FROM ".DB_PRE."menu WHERE keyid='member_0'"));
				@extract($db->get_one("SELECT menuid AS member_1 FROM ".DB_PRE."menu WHERE keyid='member_1'"));
				@include (PHPCMS_ROOT.$module."/install/extention.inc.php");
			}

			if(file_exists(PHPCMS_ROOT.$module."/install/templates/"))
			{
				dir_copy(PHPCMS_ROOT.$module."/install/templates/", PHPCMS_ROOT.'templates/'.TPL_NAME.'/'.$module.'/');
			}
			if(file_exists(PHPCMS_ROOT.$module."/install/languages/"))
			{
				dir_copy(PHPCMS_ROOT.$module.'/install/languages/', PHPCMS_ROOT.'languages/'.LANG.'/');
			}
			if(file_exists(PHPCMS_ROOT.'templates/'.TPL_NAME.'/'.$module.'/tag_config.inc.php'))
			{
				$data = file_get_contents(PHPCMS_ROOT.'templates/'.TPL_NAME.'/'.$module.'/tag_config.inc.php');
				$data = str_replace('phpcms2008_',DB_PRE,$data);
				file_put_contents(PHPCMS_ROOT.'templates/'.TPL_NAME.'/'.$module.'/tag_config.inc.php',$data);
			}
			if($module == 'member')
			{
				//建立管理员帐号
				if(CHARSET=='gbk') $username = iconv('UTF-8','GBK',$username);
				$password = md5(PASSWORD_KEY.$password);
				$db->query("INSERT INTO ".DB_PRE."admin (`userid`,`username`,`allowmultilogin`,`alloweditpassword`,`editpasswordnextlogin`,`disabled`) VALUES ('1','$username',1,1,0,0)");
				$db->query("INSERT INTO ".DB_PRE."admin_role (`userid`, `roleid`) VALUES(1, 1)");
				$db->query("INSERT INTO ".DB_PRE."member (`userid`,`username`,`password`,`email`,`groupid`,`modelid`) VALUES ('1','$username','$password','$email',1,10)");
				$db->query("INSERT INTO ".DB_PRE."member_info (`userid`,`regip`,`regtime`) VALUES ('1','".IP."','".TIME."')");
			}
		}
		echo $module;
		break;

	case 'dbtest':
		if(!mysql_connect($dbhost, $dbuser, $dbpw))
		{
			exit('2');
		}
		$server_info = mysql_get_server_info();
		if($server_info < '4.0') exit('6');
		if(!mysql_select_db($dbname))
	    {
			if(!@mysql_query("CREATE DATABASE `$dbname`")) exit('3');
			mysql_select_db($dbname);
		}
		$tables = array();
		$query = mysql_list_tables($dbname);
		while($r = mysql_fetch_row($query))
		{
			$tables[] = $r[0];
		}
		if($tables && in_array($tablepre.'module', $tables))
	    {
			exit('0');
		}
		else
		{
			exit('1');
		}
		break;

	case 'install_hdwiki':
		
		break;
	case 'cache_all':

		$dbclass = 'db_'.DB_DATABASE;
		require $dbclass.'.class.php';
		$db = new $dbclass;
		$db->connect(DB_HOST, DB_USER, DB_PW, DB_NAME, DB_PCONNECT, DB_CHARSET);

		require 'cache.func.php';
		cache_all();
		$cache = cache_read('common.php');

		tags_update(array_keys($cache['MODULE']));

		require 'admin/model.class.php';
        $model = new model();
		$model->cache();
		$model->cache_field(1);
		$model->cache_field(2);
		$model->cache_field(3);
		$model->cache_field(4);
		$model->cache_field(5);
		$model->cache_field(6);
		require 'member/admin/include/model_member.class.php';
		$member_model = new member_model();
		$member_model->cache();
		$member_model->cache_field(10);
		//开始安装Hdwiki
		if(file_exists(PHPCMS_ROOT.'hdwiki/install/hdwiki.sql'))
		{
			$sql = file_get_contents(PHPCMS_ROOT.'hdwiki/install/hdwiki.sql');
			$sql = str_replace('wiki_',DB_PRE.'wiki_',$sql);
			sql_execute($sql);

	//		file_put_contents(PHPCMS_ROOT."a.txt",$sql);
			$config = "<?php\r\n";
			$config .= "define('DB_HOST', '".DB_HOST."');
define('DB_USER', '".DB_USER."');
define('DB_PW', '".DB_PW."');
define('DB_NAME', '".DB_NAME."');
define('DB_CHARSET', '".DB_CHARSET."');
define('DB_TABLEPRE', '".DB_PRE."wiki_');
define('DB_CONNECT', 0);
define('WIKI_CHARSET', '".CHARSET."');\r\n";
			$config .= "?>";
$PP_KEY = random(20, 'abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ');

$passport_config = "<?php\r\n";
$passport_config .= "define('PP_OPEN', '1');
define('PP_TYPE', 'client');
define('PP_API', '".substr(SITE_URL,0,-1)."');
define('PP_NAME', 'PHPCMS');
define('PP_LOGIN', '/member/login.php');
define('PP_LOGOUT', '/member/logout.php?');
define('PP_REG', '/member/register.php');
define('PP_KEY', '$PP_KEY');\r\n";
$passport_config .= "?>";
file_put_contents(PHPCMS_ROOT.'hdwiki/data/passport.inc.php',$passport_config);

$r = $db->get_one("SELECT *  FROM ".DB_PRE."module WHERE `module`='phpcms'");
$array_setting = string2array($r['setting']);
$array_setting['enablepassport'] = 1;
$array_setting['hdwiki'] = 'hdwiki';
$array_setting['passport_file'] = 'hdwiki';
$array_setting['passport_charset'] = 'gbk';
$array_setting['passport_url'] = SITE_URL.'hdwiki/';
$array_setting['passport_key'] = $PP_KEY;
$string_setting = array2string($array_setting);

$db->query("UPDATE ".DB_PRE."module SET `setting`='$string_setting' WHERE `module`='phpcms'");
	$site_name = '我的HDwiki';
	$site_url = SITE_URL.'hdwiki';
	$admin_email = $email;
	$admin_master = $username;
	$adminpwd = md5($password);
	$regtime = TIME;
	$auth_key = random(20, 'abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ');

			$installsql = <<<EOT

INSERT INTO wiki_usergroup (`groupid`, `grouptitle`, `regulars`, `default`, `type`, `creditslower`, `creditshigher`, `stars`, `color`, `groupavatar`) VALUES
(1, '匿名用户', 'index-default|index-setstyle|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-getpass|user-code|user-space|user-clearcookies|synonym-view|passport_client-login|passport_client-register', 'index-default|index-setstyle|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-getpass|user-code|user-space|user-clearcookies|synonym-view|passport_client-login|passport_client-register', 1, 0, 0, 0, '', ''),
(3, '词条管理员', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|doc-setfocus|doc-getcategroytree|doc-changecategory|doc-changename|doc-lock|doc-unlock|doc-audit|doc-remove|comment-delete|comment-add|comment-edit|edition-remove|edition-excellent|edition-unexcellent|edition-copy|synonym-removesynonym|synonym-view|synonym-savesynonym|doc-immunity|admin_main-logout|admin_main-mainframe|admin_main-update|admin_doc-default|admin_doc-search|admin_doc-audit|admin_doc-recommend|admin_doc-lock|admin_doc-unlock|admin_doc-remove|admin_doc-move|admin_doc-rename|admin_comment-default|admin_comment-search|admin_comment-delete|admin_attachment-default|admin_attachment-search|admin_attachment-remove|admin_attachment-download|admin_focus-focuslist|admin_focus-remove|admin_focus-reorder|admin_focus-edit|admin_focus-updateimg|admin_focus-numset|admin_tag-hottag|admin_word-default|admin_synonym-default|admin_synonym-search|admin_synonym-delete|admin_synonym-save|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|doc-setfocus|doc-getcategroytree|doc-changecategory|doc-changename|doc-lock|doc-unlock|doc-audit|doc-remove|comment-delete|comment-add|comment-edit|edition-remove|edition-excellent|edition-unexcellent|edition-copy|synonym-removesynonym|synonym-view|synonym-savesynonym|doc-immunity|admin_main-logout|admin_main-mainframe|admin_main-update|admin_doc-default|admin_doc-search|admin_doc-audit|admin_doc-recommend|admin_doc-lock|admin_doc-unlock|admin_doc-remove|admin_doc-move|admin_doc-rename|admin_comment-default|admin_comment-search|admin_comment-delete|admin_attachment-default|admin_attachment-search|admin_attachment-remove|admin_attachment-download|admin_focus-focuslist|admin_focus-remove|admin_focus-reorder|admin_focus-edit|admin_focus-updateimg|admin_focus-numset|admin_tag-hottag|admin_word-default|admin_synonym-default|admin_synonym-search|admin_synonym-delete|admin_synonym-save|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 1, 0, 0, 2, '', ''),
(4, '超级管理员', '', '', 1, 0, 0, 3, '', ''),
(5, '白丁', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|doc-edit|doc-sandbox|comment-add|synonym-view|synonym-savesynonym|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|doc-edit|doc-sandbox|comment-add|synonym-view|synonym-savesynonym|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 2, -999999, 0, 0, '', ''),
(2, '书童', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|comment-add|synonym-removesynonym|synonym-view|synonym-savesynonym|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|comment-add|synonym-removesynonym|synonym-view|synonym-savesynonym|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 2, 0, 100, 1, '', ''),
(6, '秀才', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|comment-add|synonym-removesynonym|synonym-view|synonym-savesynonym|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|comment-add|synonym-removesynonym|synonym-view|synonym-savesynonym|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 2, 100, 300, 4, '', ''),
(7, '举人', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|comment-add|synonym-removesynonym|synonym-view|synonym-savesynonym|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|comment-add|synonym-removesynonym|synonym-view|synonym-savesynonym|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 2, 300, 600, 5, '', ''),
(8, '进士', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|comment-add|synonym-removesynonym|synonym-view|synonym-savesynonym|doc-immunity|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|comment-add|synonym-removesynonym|synonym-view|synonym-savesynonym|doc-immunity|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 2, 600, 1000, 8, '', ''),
(9, '状元', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|comment-add|synonym-removesynonym|synonym-view|synonym-savesynonym|doc-immunity|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|comment-add|synonym-removesynonym|synonym-view|synonym-savesynonym|doc-immunity|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 2, 1000, 1500, 16, '', ''),
(10, '翰林', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|comment-add|synonym-removesynonym|synonym-view|synonym-savesynonym|doc-immunity|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|comment-add|synonym-removesynonym|synonym-view|synonym-savesynonym|doc-immunity|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 2, 1500, 2100, 18, '', ''),
(11, '太傅', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|doc-setfocus|doc-changename|doc-lock|doc-unlock|doc-audit|comment-add|comment-edit|edition-excellent|edition-unexcellent|edition-copy|synonym-removesynonym|synonym-view|synonym-savesynonym|doc-immunity|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|doc-setfocus|doc-changename|doc-lock|doc-unlock|doc-audit|comment-add|comment-edit|edition-excellent|edition-unexcellent|edition-copy|synonym-removesynonym|synonym-view|synonym-savesynonym|doc-immunity|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 2, 2100, 2800, 24, '', ''),
(12, '圣贤', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|doc-setfocus|doc-getcategroytree|doc-changecategory|doc-changename|doc-lock|doc-unlock|doc-audit|comment-add|comment-edit|edition-excellent|edition-unexcellent|edition-copy|synonym-removesynonym|synonym-view|synonym-savesynonym|doc-immunity|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|doc-setfocus|doc-getcategroytree|doc-changecategory|doc-changename|doc-lock|doc-unlock|doc-audit|comment-add|comment-edit|edition-excellent|edition-unexcellent|edition-copy|synonym-removesynonym|synonym-view|synonym-savesynonym|doc-immunity|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 2, 2800, 999999999, 33, '', ''),
(13, '荣誉宰相', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|doc-setfocus|doc-changename|doc-audit|comment-add|comment-edit|edition-excellent|edition-unexcellent|edition-copy|synonym-removesynonym|synonym-view|synonym-savesynonym|doc-immunity|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|doc-setfocus|doc-changename|doc-audit|comment-add|comment-edit|edition-excellent|edition-unexcellent|edition-copy|synonym-removesynonym|synonym-view|synonym-savesynonym|doc-immunity|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 0, 0, 0, 5, '', ''),
(14, '管理员', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|doc-setfocus|doc-getcategroytree|doc-changecategory|doc-changename|doc-lock|doc-unlock|doc-audit|doc-remove|comment-delete|comment-add|comment-edit|edition-remove|edition-excellent|edition-unexcellent|edition-copy|synonym-removesynonym|synonym-view|synonym-savesynonym|doc-immunity|admin_banned-default|admin_friendlink-default|admin_friendlink-add|admin_friendlink-edit|admin_friendlink-remove|admin_friendlink-updateorder|admin_main-login|admin_main-default|admin_main-logout|admin_main-mainframe|admin_main-update|admin_setting-base|admin_setting-logo|admin_setting-credit|admin_setting-seo|admin_setting-cache|admin_setting-updatecache|admin_setting-removecache|admin_setting-attachment|admin_setting-mail|admin_task-default|admin_task-taskstatus|admin_task-edittask|admin_task-run|admin_log-default|admin_setting-notice|admin_plugin-list|admin_plugin-default|admin_plugin-manage|admin_plugin-install|admin_plugin-uninstall|admin_plugin-start|admin_plugin-stop|admin_plugin-setvar|admin_plugin-hook|admin_doc-default|admin_doc-search|admin_doc-audit|admin_doc-recommend|admin_doc-lock|admin_doc-unlock|admin_doc-remove|admin_doc-move|admin_doc-rename|admin_comment-default|admin_comment-search|admin_comment-delete|admin_attachment-default|admin_attachment-search|admin_attachment-remove|admin_attachment-download|admin_focus-focuslist|admin_focus-remove|admin_focus-reorder|admin_focus-edit|admin_focus-updateimg|admin_focus-numset|admin_tag-hottag|admin_word-default|admin_synonym-default|admin_synonym-search|admin_synonym-delete|admin_synonym-save|admin_user-default|admin_user-list|admin_user-add|admin_user-edit|admin_usergroup-default|admin_usergroup-list|admin_category-default|admin_category-list|admin_category-add|admin_category-edit|admin_category-reorder|admin_statistics-stand|admin_statistics-cat_toplist|admin_statistics-doc_toplist|admin_statistics-edit_toplist|admin_statistics-credit_toplist|admin_statistics-admin_team|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 'index-default|index-setstyle|attachment-download|category-default|category-ajax|category-view|category-letter|list-letter|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-editimage|user-getpass|user-code|user-space|user-clearcookies|user-cutoutimage|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|attachment-uploadimg|attachment-remove|doc-create|doc-verify|doc-edit|doc-editsection|doc-refresheditlock|doc-unseteditlock|doc-sandbox|doc-setfocus|doc-getcategroytree|doc-changecategory|doc-changename|doc-lock|doc-unlock|doc-audit|doc-remove|comment-delete|comment-add|comment-edit|edition-remove|edition-excellent|edition-unexcellent|edition-copy|synonym-removesynonym|synonym-view|synonym-savesynonym|doc-immunity|admin_banned-default|admin_friendlink-default|admin_friendlink-add|admin_friendlink-edit|admin_friendlink-remove|admin_friendlink-updateorder|admin_main-login|admin_main-default|admin_main-logout|admin_main-mainframe|admin_main-update|admin_setting-base|admin_setting-logo|admin_setting-credit|admin_setting-seo|admin_setting-cache|admin_setting-updatecache|admin_setting-removecache|admin_setting-attachment|admin_setting-mail|admin_task-default|admin_task-taskstatus|admin_task-edittask|admin_task-run|admin_log-default|admin_setting-notice|admin_plugin-list|admin_plugin-default|admin_plugin-manage|admin_plugin-install|admin_plugin-uninstall|admin_plugin-start|admin_plugin-stop|admin_plugin-setvar|admin_plugin-hook|admin_doc-default|admin_doc-search|admin_doc-audit|admin_doc-recommend|admin_doc-lock|admin_doc-unlock|admin_doc-remove|admin_doc-move|admin_doc-rename|admin_comment-default|admin_comment-search|admin_comment-delete|admin_attachment-default|admin_attachment-search|admin_attachment-remove|admin_attachment-download|admin_focus-focuslist|admin_focus-remove|admin_focus-reorder|admin_focus-edit|admin_focus-updateimg|admin_focus-numset|admin_tag-hottag|admin_word-default|admin_synonym-default|admin_synonym-search|admin_synonym-delete|admin_synonym-save|admin_user-default|admin_user-list|admin_user-add|admin_user-edit|admin_usergroup-default|admin_usergroup-list|admin_category-default|admin_category-list|admin_category-add|admin_category-edit|admin_category-reorder|admin_statistics-stand|admin_statistics-cat_toplist|admin_statistics-doc_toplist|admin_statistics-edit_toplist|admin_statistics-credit_toplist|admin_statistics-admin_team|exchange-default|passport_client-login|passport_client-register|passport_client-logout', 1, 0, 0, 2, '', ''),
(15, '被删除', 'index-default|index-setstyle|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-getpass|user-code|user-space|user-clearcookies|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|synonym-view', 'index-default|index-setstyle|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-logout|user-profile|user-editprofile|user-editpass|user-getpass|user-code|user-space|user-clearcookies|pms-default|pms-box|pms-setread|pms-remove|pms-sendmessage|pms-checkrecipient|pms-blacklist|synonym-view', 1, 0, 0, 1, '', '');

REPLACE INTO wiki_setting(variable,value) VALUES
	('site_name', '{$site_name}'),
	('site_url', '{$site_url}'),
	('site_icp', ''),
	('cookie_domain', ''),
	('cookie_pre', 'hd_'),
	('app_url', 'http://kaiyuan.hudong.com'),
	('auth_key', '{$auth_key}'),


	('verify_doc', '0'),
	('cat_intro_set','0'),
	('time_offset','8'),
	('time_diff','0'),
	('time_format',''),
	('date_format','m-d'),
	('style_user_select','1'),

	('credit_create', '5'),
	('credit_edit', '3'),
	('credit_upload', '2'),
	('credit_register', '20'),
	('credit_login', '1'),
	('credit_pms','1'),
	('credit_comment','2'),
	('list_prepage', '20'),
	
	('list_focus', '10'),
	('list_recentupdate', '10'),
	('list_weekuser', '10'),
	('list_allcredit', '10'),
	('list_popularity', '10'),
	('list_letter', '10'),
	('category_view', '10'),
	('category_letter', '10'),
	('index_commend', '5'),
	('index_recentupdate', '15'),
	('index_weekuser', '10'),
	('index_topuser', '10'),
	('index_recentcomment', '8'),

	('seo_prefix', 'index.php?'),
	('seo_separator', '-'),
	('seo_suffix', ''),
	('seo_title', ''),
	('seo_keywords', ''),
	('seo_description', ''),
	('seo_headers', ''),
	('seo_type', '0'),
	('seo_type_doc', '0'),

	('attachment_size', '2048'),
	('attachment_open', '0'),
	('attachment_type', 'jpg|jpeg|bmp|gif|png|gz|bz2|zip|rar|doc|ppt|mp3|xls|txt|swf|flv|php'),
		
	('index_cache_time', '300'),
	('list_cache_time', '300'),
	('doc_cache_time', '300'),
	('tpl_name', 'default'),
	('style_name','default'),
	('lang_name','zh'),
	('auto_picture','0'),
	('checkcode','3'),
	('sandbox_id',''),
	('site_notice','本站是由<span style="color:#FF0000">1</span>位网民共同撰写的百科全书，目前已收录词条<span style="color:#FF0000"> 0</span>个'),

	
	('search_time', '1'),
	('search_tip_switch', '1'),
	('search_num', '10000'),
	('close_register_reason', '对不起，网站暂停注册！给您带来的不便还请谅解。'),
	('error_names', '管理员'),
	('register_check', '0'),
	('name_min_length', '3'),
	('name_max_length', '15'),
	('register_least_minute', '30'),
	('allow_register', '1'),
	('close_website', '0'),
	('close_website_reason', '网站暂时关闭，马上就会恢复，请稍候关注，谢谢。');
				 
INSERT INTO wiki_category(`name`,`navigation`,`docs`) VALUES ('Default','a:1:{i:0;a:2:{s:3:"cid";s:1:"1";s:4:"name";s:7:"Default";}}',0);
INSERT INTO wiki_user(email,username,`password`,`lastip`,groupid,credits,regtime) VALUES ('{$admin_email}', '{$admin_master}', '$adminpwd', '{$_SERVER[REMOTE_ADDR]}',4,20,'$regtime') ;
INSERT INTO wiki_creditdetail(`uid`,`operation`,`credit`,`time`) VALUES (1,'user-register',20,$regtime);


INSERT INTO wiki_regular (`id`, `name`, `regular`, `type`, `regulargroupid`) VALUES
	(1, '??访问首页', 'index-default', 0, 18),
	(2, '更改风格', 'index-setstyle', 0, 18),
	(3, '图片上传', 'attachment-uploadimg', 0, 20),
	(4, '附件下载（附件）', 'attachment-download', 0, 18),
	(5, '删除附件（附件）', 'attachment-remove', 0, 20),
	(6, '浏览分类', 'category-default|category-ajax', 0, 18),
	(7, '浏览具体分类', 'category-view', 0, 18),
	(8, '分类下字母顺序浏览', 'category-letter', 0, 18),
	(9, '按字母顺序浏览（排行榜）', 'list-letter', 0, 18),
	(10, '最近更新词条（排行榜）', 'list-default|list-recentupdate', 0, 18),
	(13, '用户人气词条列表(排行榜)', 'list-popularity', 0, 18),
	(14, '推荐词条列表(排行榜)', 'list-focus', 0, 18),
	(15, '浏览词条', 'doc-view', 0, 18),
	(16, '创建词条', 'doc-create', 0, 20),
	(17, '验证词条是否存在', 'doc-verify', 0, 20),
	(18, '编辑词条', 'doc-edit', 0, 20),
	(19, '分段编辑词条', 'doc-editsection', 0, 20),
	(20, '刷新编辑锁', 'doc-refresheditlock', 0, 20),
	(21, '取消编辑锁', 'doc-unseteditlock', 0, 20),
	(22, '浏览词条内链', 'doc-innerlink', 0, 18),
	(23, '浏览词条摘要', 'doc-summary', 0, 18),
	(24, '浏览词条贡献者', 'doc-editor', 0, 18),
	(25, '沙盒', 'doc-sandbox', 0, 20),
	(26, '设置推荐词条（前台词条管理）', 'doc-setfocus', 0, 20),
	(27, '移动词条分类（前台词条管理）', 'doc-getcategroytree|doc-changecategory', 0, 20),
	(28, '更改词条名（前台词条管理）', 'doc-changename', 0, 20),
	(29, '锁定词条（前台词条管理）', 'doc-lock', 0, 20),
	(30, '解除词条锁定（前台词条管理）', 'doc-unlock', 0, 20),
	(31, '审核词条（前台词条管理）', 'doc-audit', 0, 20),
	(32, '删除词条（前台词条管理）', 'doc-remove', 0, 20),
	(33, '查看评论', 'comment-view', 0, 18),
	(34, '删除评论（前台评论管理）', 'comment-delete', 0, 20),
	(35, '添加评论（前台评论管理）', 'comment-add', 0, 20),
	(36, '编辑评论（前台评论管理）', 'comment-edit', 0, 20),
	(37, '版本列表（历史版本）', 'edition-list', 0, 18),
	(38, '浏览版本（历史版本）', 'edition-view', 0, 18),
	(39, '版本对比（历史版本）', 'edition-compare', 0, 18),
	(40, '删除版本（历史版本）', 'edition-remove', 0, 20),
	(41, '优秀版本（历史版本）', 'edition-excellent', 0, 20),
	(42, '取消优秀（历史版本）', 'edition-unexcellent', 0, 20),
	(43, '复制版本（历史版本）', 'edition-copy', 0, 20),
	(44, '进入词条（搜索）', 'search-default', 0, 18),
	(45, '全文搜索（搜索）', 'search-fulltext', 0, 18),
	(46, 'TAG搜索（搜索）', 'search-tag', 0, 18),
	(47, '用户注册（用户）', 'user-register', 0, 19),
	(48, '用户登录（用户）', 'user-login', 0, 19),
	(49, '检测用户（用户）', 'user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail', 0, 19),
	(50, '用户注销（用户）', 'user-logout', 0, 19),
	(51, '个人信息（用户）', 'user-profile', 0, 19),
	(52, '个人信息设置（用户）', 'user-editprofile', 0, 19),
	(53, '修改密码（用户）', 'user-editpass', 0, 19),
	(54, '修改头像（用户）', 'user-editimage', 0, 19),
	(55, '找回密码（用户）', 'user-getpass', 0, 19),
	(56, '显示验证码（用户）', 'user-code', 0, 19),
	(57, '个人空间（用户）', 'user-space', 0, 19),
	(58, '清除cookies（用户）', 'user-clearcookies', 0, 19),
	(59, 'IP禁止', 'admin_banned-default', 1, 21),
	(60, '分类管理列表（分类管理）', 'admin_category-default|admin_category-list', 1, 25),
	(61, '添加分类（分类管理）', 'admin_category-add', 1, 25),
	(62, '编辑分类（分类管理）', 'admin_category-edit', 1, 25),
	(63, '删除分类（分类管理）', 'admin_category-remove', 1, 25),
	(64, '分类排序（分类管理）', 'admin_category-reorder', 1, 25),
	(65, '分类合并（分类管理）', 'admin_category-merge', 1, 25),
	(66, '数据库备份（数据库管理）', 'admin_db-backup', 1, 27),
	(67, '数据库还原（数据库管理）', 'admin_db-import', 1, 27),
	(68, '删除数据文件（数据库管理）', 'admin_db-remove', 1, 27),
	(69, '数据库列表（数据库管理）', 'admin_db-tablelist', 1, 27),
	(70, '数据库优化（数据库管理）', 'admin_db-optimize', 1, 27),
	(71, '数据库修复（数据库管理）', 'admin_db-repair', 1, 27),
	(72, '下载数据文件（数据库管理）', 'admin_db-downloadfile', 1, 27),
	(73, '词条列表（管理词条）', 'admin_doc-default', 1, 23),
	(74, '搜索词条（管理词条）', 'admin_doc-search', 1, 23),
	(75, '审核词条（管理词条）', 'admin_doc-audit', 1, 23),
	(76, '推荐词条（管理词条）', 'admin_doc-recommend', 1, 23),
	(77, '锁定词条（管理词条）', 'admin_doc-lock', 1, 23),
	(78, '解锁词条（管理词条）', 'admin_doc-unlock', 1, 23),
	(79, '删除词条（管理词条）', 'admin_doc-remove', 1, 23),
	(80, '移动词条（管理词条）', 'admin_doc-move', 1, 23),
	(81, '重命名词条（管理词条）', 'admin_doc-rename', 1, 23),
	(82, '搜索评论（后台管理评论）', 'admin_comment-default|admin_comment-search', 1, 23),
	(83, '删除评论（后台管理评论）', 'admin_comment-delete', 1, 23),
	(84, '搜索附件（后台管理附件）', 'admin_attachment-default|admin_attachment-search', 1, 23),
	(85, '删除附件（后台管理附件）', 'admin_attachment-remove', 1, 23),
	(86, '下载附件（后台管理附件）', 'admin_attachment-download', 1, 23),
	(87, '推荐词条列表（推荐词条）', 'admin_focus-focuslist', 1, 23),
	(88, '删除推荐词条（推荐词条）', 'admin_focus-remove', 1, 23),
	(89, '更改推荐词条顺序（推荐词条）', 'admin_focus-reorder', 1, 23),
	(90, '编辑推荐词条（推荐词条）', 'admin_focus-edit', 1, 23),
	(91, '更新图片（推荐词条）', 'admin_focus-updateimg', 1, 23),
	(92, '词条显示数量设置（推荐词条）', 'admin_focus-numset', 1, 23),
	(93, '友情链接列表（友情链接）', 'admin_friendlink-default', 1, 21),
	(94, '添加友情链接（友情链接）', 'admin_friendlink-add', 1, 21),
	(95, '编辑友情链接（友情链接）', 'admin_friendlink-edit', 1, 21),
	(96, '删除友情链接（友情链接）', 'admin_friendlink-remove', 1, 21),
	(97, '更新友情链接顺序（友情链接）', 'admin_friendlink-updateorder', 1, 21),
	(98, '语言列表（语言）', 'admin_language-default', 1, 26),
	(99, '添加语言（语言）', 'admin_language-addlanguage', 1, 26),
	(100, '删除语言（语言）', 'admin_language-removelanguage', 1, 26),
	(101, '更新语言（语言）', 'admin_language-updatelanguage', 1, 26),
	(102, '设置默认语言（语言）', 'admin_language-setdefaultlanguage', 1, 26),
	(103, '管理员登录（后台登录）', 'admin_main-login|admin_main-default', 1, 21),
	(104, '管理员退出（后台登录）', 'admin_main-logout', 1, 21),
	(105, '后台框架（后台登录）', 'admin_main-mainframe', 1, 21),
	(106, '后台新版本提示（后台登录）', 'admin_main-update', 1, 21),
	(107, '插件列表（插件管理）', 'admin_plugin-list|admin_plugin-default|admin_plugin-manage', 1, 22),
	(108, '安装插件（插件管理）', 'admin_plugin-install', 1, 22),
	(109, '卸载插件（插件管理）', 'admin_plugin-uninstall', 1, 22),
	(110, '启用插件（插件管理）', 'admin_plugin-start', 1, 22),
	(111, '停用插件（插件管理）', 'admin_plugin-stop', 1, 22),
	(112, '插件变量（插件管理）', 'admin_plugin-setvar', 1, 22),
	(113, '插件钩子（插件管理）', 'admin_plugin-hook', 1, 22),
	(114, '规则列表(管理权限)', 'admin_regular-list|admin_regular-default', 1, 24),
	(115, '添加规则(管理权限)', 'admin_regular-add', 1, 24),
	(116, '编辑规则(管理权限)', 'admin_regular-edit', 1, 24),
	(117, '删除规则(管理权限)', 'admin_regular-remove', 1, 24),
	(118, '基本设置(网站管理)', 'admin_setting-base', 1, 21),
	(119, '上传logo(网站管理)', 'admin_setting-logo', 1, 21),
	(120, '积分设置(网站管理)', 'admin_setting-credit', 1, 21),
	(121, 'seo设置(网站管理)', 'admin_setting-seo', 1, 21),
	(122, '缓存页面(网站管理)', 'admin_setting-cache', 1, 21),
	(123, '更新缓存设置(网站管理)', 'admin_setting-updatecache', 1, 21),
	(124, '清除缓存(网站管理)', 'admin_setting-removecache', 1, 21),
	(125, '附件设置(网站管理)', 'admin_setting-attachment', 1, 21),
	(126, '邮件设置(网站管理)', 'admin_setting-mail', 1, 21),
	(127, '风格列表（风格）', 'admin_style-default', 1, 26),
	(128, '创建模版风格页面（风格）', 'admin_style-create', 1, 26),
	(129, '删除风格（风格）', 'admin_style-removestyle', 1, 26),
	(131, '设置默认风格（风格）', 'admin_style-setdefaultstyle', 1, 26),
	(132, '热门标签设置（热门标签）', 'admin_tag-hottag', 1, 23),
	(133, '列表|添加|删除（定时任务）', 'admin_task-default', 1, 21),
	(134, '启用|停用（定时任务）', 'admin_task-taskstatus', 1, 21),
	(135, '编辑定时任务（定时任务）', 'admin_task-edittask', 1, 21),
	(136, '执行定时任务（定时任务）', 'admin_task-run', 1, 21),
	(137, '用户列表（管理用户）', 'admin_user-default|admin_user-list', 1, 24),
	(138, '添加用户（管理用户）', 'admin_user-add', 1, 24),
	(139, '编辑用户（管理用户）', 'admin_user-edit', 1, 24),
	(140, '删除用户（管理用户）', 'admin_user-remove', 1, 24),
	(141, '用户组列表（管理用户组）', 'admin_usergroup-default|admin_usergroup-list', 1, 24),
	(142, '添加用户组（管理用户组）', 'admin_usergroup-add', 1, 24),
	(143, '编辑用户组（管理用户组）', 'admin_usergroup-edit', 1, 24),
	(144, '删除用户组（管理用户组）', 'admin_usergroup-remove', 1, 24),
	(145, '关键词过滤(词语过滤)', 'admin_word-default', 1, 23),
	(146, '裁剪图片', 'user-cutoutimage', 0, 19),
	(147, '上周贡献榜', 'list-weekuserlist', 0, 18),
	(148, '总贡献榜', 'list-allcredit', 0, 18),
	(149, '修改用户组(管理用户组)', 'admin_usergroup-change', 1, 24),
	(150, 'Rss订阅', 'list-rss', 0, 18),
	(151, '后台操作记录(网站管理)', 'admin_log-default', 1, 21),
	(152, '查收短消息', 'pms-default|pms-box|pms-setread', 0, 19),
	(153, '删除短消息', 'pms-remove', 0, 19),
	(154, '发送短消息', 'pms-sendmessage|pms-checkrecipient', 0, 19),
	(155, '忽略列表', 'pms-blacklist', 0, 19),
	(156, '站内公告(网站管理)', 'admin_setting-notice', 1, 21),
	(157, '删除同义词(前台同义词管理)', 'synonym-removesynonym', 0, 20),
	(158, '查看同义词(前台同义词管理)', 'synonym-view', 0, 20),
	(159, '编辑同义词(前台同义词管理)', 'synonym-savesynonym', 0, 20),
	(160, '同义词列表(后台同义词管理)', 'admin_synonym-default', 1, 23),
	(161, '搜索同义词(后台同义词管理)', 'admin_synonym-search', 1, 23),
	(162, '删除同义词(后台同义词管理)', 'admin_synonym-delete', 1, 23),
	(163, '编辑同义词(后台同义词管理)', 'admin_synonym-save', 1, 23),
	(164, '基本概况统计(后台统计)', 'admin_statistics-stand', 1, 28),
	(165, '分类排行榜(后台统计)', 'admin_statistics-cat_toplist', 1, 28),
	(166, '词条排行榜(后台统计)', 'admin_statistics-doc_toplist', 1, 28),
	(167, '编辑排行榜(后台统计)', 'admin_statistics-edit_toplist', 1, 28),
	(168, '积分排行榜(后台统计)', 'admin_statistics-credit_toplist', 1, 28),
	(169, '管理团队(后台统计)', 'admin_statistics-admin_team', 1, 28),
	(170, 'UC积分兑换', 'exchange-default', 2, 19),
	(174, '词条免检', 'doc-immunity', 0, 20),
	(176, '编辑模版文件（风格）', 'admin_style-editxml', 1, 26),
	(177, '编辑模版描述文件（风格）', 'admin_style-edit', 1, 26),
	(178, '读取模版文件（风格）', 'admin_style-readfile', 1, 26),
	(179, '保存模版文件（风格）', 'admin_style-savefile', 1, 26),
	(181, '卸载模版（风格）', 'admin_style-removestyle', 1, 26),
	(183, '可安装模版列表（风格）', 'admin_style-list', 1, 26),
	(184, '安装模版（风格）', 'admin_style-install', 1, 26),
	(185, '显示广告列表', 'admin_adv-default', 0, 21),
	(186, '设置广告加载方式', 'admin_adv-config', 0, 21),
	(187, '搜索广告(后台)', 'admin_adv-search', 0, 21),
	(188, '添加广告', 'admin_adv-add', 0, 21),
	(189, '编辑广告', 'admin_adv-edit', 0, 21),
	(190, '删除广告', 'admin_adv-remove', 0, 21),
	(191, '审核用户', 'admin_user-checkup', 0, 19),
	(192, '用户审核(取消)', 'admin_user-uncheckeduser', 0, 19),
	(193, '注册控制', 'admin_setting-baseregister', 0, 21),
	(201, '随便看看', 'doc-random', 0, 18),
	(202, '此词条对我有用', 'doc-vote', 0, 18),
	(203, '创建新风格页面', 'admin_style-add', 0, 26),
	(204, '创建新风格', 'admin_style-createstyle', 0, 26),
	(206, '频道列表（频道）', 'admin_channel-default', 1, 21),
	(207, '添加频道（频道）', 'admin_channel-add', 1, 21),
	(208, '编辑频道（频道）', 'admin_channel-edit', 1, 21),
	(209, '删除频道（频道）', 'admin_channel-remove', 1, 21),
	(210, '修改频道显示顺序（频道）', 'admin_channel-updateorder', 1, 21),
	(211, '频道列表（频道）', 'admin_channel-default', 1, 21),
	(212, '添加频道（频道）', 'admin_channel-add', 1, 21),
	(213, '编辑频道（频道）', 'admin_channel-edit', 1, 21),
	(214, '删除频道（频道）', 'admin_channel-remove', 1, 21),
	(215, '修改频道显示顺序（频道）', 'admin_channel-updateorder', 1, 21);


	
	
INSERT INTO wiki_language (`name`, `available`, `path`, `copyright`) VALUES 
	('简体中文', 1, 'zh', 'hudong.com');

INSERT INTO wiki_style (`name`, `available`, `path`, `copyright`, `css`) VALUES
	('默认风格', 1, 'default', 'hudong.com', 'a:18:{s:8:"bg_color";s:11:"transparent";s:14:"left_framcolor";s:7:"#e6e6e6";s:16:"leftitle_bgcolor";s:7:"#f7f7f8";s:18:"leftitle_framcolor";s:7:"#efefef";s:16:"middle_framcolor";s:7:"#eaf1f6";s:19:"middletitle_bgcolor";s:7:"#eaf6fd";s:21:"middletitle_framcolor";s:7:"#c4d2db";s:15:"right_framcolor";s:7:"#cef2e0";s:17:"rightitle_bgcolor";s:7:"#cef2e0";s:19:"rightitle_framcolor";s:7:"#a3bfb1";s:13:"nav_framcolor";s:7:"#cdcdcd";s:11:"nav_bgcolor";s:7:"#aaaeb1";s:13:"nav_linkcolor";s:4:"#fff";s:13:"nav_overcolor";s:4:"#ff0";s:8:"nav_size";s:4:"14px";s:10:"bg_imgname";s:11:"html_bg.jpg";s:13:"titbg_imgname";s:10:"col_bg.jpg";s:4:"path";s:7:"default";}');


INSERT INTO wiki_regulargroup (`id`, `title`, `size`, `type`) VALUES
	(18, '页面浏览', 0, 0),
	(19, '用户操作', 0, 0),
	(20, '词条管理', 0, 0),
	(21, '网站管理', 0, 1),
	(22, '插件管理', 0, 1),
	(23, '内容管理', 0, 1),
	(24, '用户管理', 0, 1),
	(25, '分类管理', 0, 1),
	(26, '语言/风格', 0, 1),
	(27, '数据库管理', 0, 1),
	(28, '站内统计', 0, 1);

INSERT INTO wiki_regular_relation (`idleft`, `idright`) VALUES
	(5, 3),
	(5, 18),
	(19, 18),
	(21, 29),
	(21, 20),
	(30, 29),
	(34, 36),
	(40, 43),
	(40, 41),
	(40, 42),
	(48, 50),
	(52, 51),
	(53, 51),
	(54, 51),
	(62, 60),
	(63, 64),
	(63, 65),
	(63, 60),
	(63, 61),
	(63, 62),
	(65, 64),
	(67, 70),
	(67, 69),
	(67, 71),
	(67, 72),
	(67, 68),
	(67, 66),
	(68, 72),
	(68, 71),
	(68, 70),
	(68, 69),
	(68, 66),
	(71, 69),
	(79, 162),
	(79, 83),
	(79, 80),
	(79, 78),
	(79, 77),
	(79, 75),
	(79, 85),
	(79, 81),
	(79, 73),
	(88, 87),
	(88, 89),
	(88, 90),
	(88, 92),
	(88, 91),
	(96, 95),
	(96, 93),
	(96, 94),
	(96, 97),
	(100, 98),
	(100, 99),
	(100, 101),
	(100, 102),
	(102, 101),
	(109, 108),
	(109, 113),
	(109, 112),
	(109, 111),
	(109, 110),
	(109, 107),
	(117, 114),
	(117, 116),
	(117, 115),
	(129, 127),
	(129, 131),
	(129, 130),
	(129, 128),
	(131, 130),
	(140, 137),
	(140, 138),
	(140, 139),
	(144, 143),
	(144, 142),
	(144, 141),
	(152, 51),
	(153, 51),
	(153, 154),
	(153, 155),
	(153, 152),
	(154, 51),
	(155, 51),
	(157, 159),
	(157, 158),
	(162, 161),
	(162, 160),
	(162, 163);

EOT;
			$sql = str_replace('wiki_',DB_PRE.'wiki_',$installsql);
			sql_execute($sql);
			file_put_contents(PHPCMS_ROOT."hdwiki/config.php",$config);
			file_put_contents(PHPCMS_ROOT.'hdwiki/data/install.lock','');
		cache_common();
		}
		//开始安装Hdwiki结束
        file_put_contents(PHPCMS_ROOT.'data/install.lock','');
		copy(PHPCMS_ROOT."install/cms_index.html",PHPCMS_ROOT."index.html");
		$head['title'] = '网站地图';
		ob_start();
		include template('phpcms', 'sitemap');
		$file = PHPCMS_ROOT.'sitemap.html';
		createhtml($file);
		require 'session_'.SESSION_STORAGE.'.class.php';
		$session = new session();
		session_set_cookie_params(0, COOKIE_PATH, COOKIE_DOMAIN);
		session_start();
		$_SESSION['install_system'] = 1;
		@unlink(PHPCMS_ROOT.'install.php');
		break;
	case 'testdata':
		$dbclass = 'db_'.DB_DATABASE;
		require $dbclass.'.class.php';

		$db = new $dbclass;
		$db->connect(DB_HOST, DB_USER, DB_PW, DB_NAME, DB_PCONNECT, DB_CHARSET);
		if(file_exists(PHPCMS_ROOT."install/main/testsql.sql"))
		{
			$sql = file_get_contents(PHPCMS_ROOT."install/main/testsql.sql");
			sql_execute($sql);
		}
		break;
	case 'ftpset':
		if(!$ftphost || !$ftpuser) exit("<script>alert('请填写ftp服务器和ftp帐号！');</script>");
		$ftp = ftp_connect($ftphost, $ftpport, 90);
		if(!$ftp) exit("<script>alert('设置错误！无法连接到FTP服务器 ');</script>");
		$testlogin = ftp_login($ftp, $ftpuser, $ftppass);
		if(!$testlogin) exit("<script>alert('帐号或密码错误 ');</script>");
		if($ftpwebpath=='') $ftpwebpath = '/';
		$testchdir = ftp_chdir($ftp, $ftpwebpath);
		if(!$testchdir) exit("<script>alert('网站根目录相对FTP根目录".$ftpwebpath."的路径设置错误！');</script>");
		$config = array('FTP_ENABLE'=>1,
						'FTP_HOST'=>$ftphost,
						'FTP_PORT'=>$ftpport,
						'FTP_USER'=>$ftpuser,
						'FTP_PW'=>$ftppass,
						'FTP_PATH'=>$ftpwebpath
						);

		require 'ftp.class.php';
		$f = new ftp($ftphost, $ftpport, $ftpuser, $ftppass, $ftpwebpath);
		$selectmods = explode(',',$selectmod);

		foreach($selectmods AS $dir)
		{
			if($dir == 'phpcms')
			{
				$files = file(PHPCMS_ROOT."install/chmod.txt");
			}
			else
			{
				$files = file(PHPCMS_ROOT.$dir."/install/chmod.txt");
			}
			$files = array_filter($files);
			foreach($files as $file)
			{
				$file = trim($file);
				$f->dir_chmod($file, $mode);
			}
		}
		set_config($config);
		exit("<script>alert('设置成功，请刷新重新检测！');parent.location.reload();</script>");
		break;

	case 'ftpdir_list':
		require_once 'ftp.class.php';
		require_once 'form.class.php';
		$ftp = new ftp($ftphost, $ftpport, $ftpuser, $ftppw, '');
		if($ftp->error)
	    {
			exit($ftp->error);
		}
		else
	    {
			$dirs = $ftp->nlist($path);
			if($dirs)
			{
				$options = $path == '/' ? array('/'=>'/') : array(''=>'请选择');
				foreach($dirs as $k=>$v)
				{
					if(!str_exists($v, '.')) $options[$v] = $v;
				}
				if(count($options) > 1)
				{
					echo form::select($options, 'dirlist', 'dirlist', '', 1, '', 'onchange="$(\'#ftpwebpath\').val(this.value == \'/\' ? \'/\' : \''.$path.'\'+this.value+\'/\');ftpdir_list(\''.$path.'\'+this.value+\'/\')"');
				}
			}
		}
		break;
}

function _sql_execute($sql)
{
	global $db;
    $sqls = _sql_split($sql);
	if(is_array($sqls))
    {
		foreach($sqls as $sql)
		{
			if(trim($sql) != '')
			{
				$db->query($sql);
			}
		}
	}
	else
	{
		$db->query($sqls);
	}
	return true;
}

function _sql_split($sql)
{
	global $db,$dbcharset,$tablepre;
	if($db->version() > '4.1' && $dbcharset)
	{
		$sql = preg_replace("/TYPE=(InnoDB|MyISAM|MEMORY)( DEFAULT CHARSET=[^; ]+)?/", "TYPE=\\1 DEFAULT CHARSET=".$dbcharset,$sql);
	}
	if($tablepre != "phpcms_") $sql = str_replace("phpcms_", $tablepre, $sql);
	$sql = str_replace("\r", "\n", $sql);
	$ret = array();
	$num = 0;
	$queriesarray = explode(";\n", trim($sql));
	unset($sql);
	foreach($queriesarray as $query)
	{
		$ret[$num] = '';
		$queries = explode("\n", trim($query));
		$queries = array_filter($queries);
		foreach($queries as $query)
		{
			$str1 = substr($query, 0, 1);
			if($str1 != '#' && $str1 != '-') $ret[$num] .= $query;
		}
		$num++;
	}
	return $ret;
}
?>